﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using ObjectLibrary;

namespace _0912089_0912172
{
    public class Sprite2D : VisibleGameEntity2D
    {
        Color filterColor = Color.White;

        public Color FilterColor
        {
            get { return filterColor; }
            set { filterColor = value; }
        }


        public Sprite2D(ContentManager content, string fileName, Vector2 pos, bool center)
        {
            _texture = content.Load<Texture2D>(fileName);
            if(center)
            {
                pos.X -= _texture.Width/2;
                pos.Y -= _texture.Height/2;
            }
            _position = pos;
        }
        public Sprite2D(Texture2D texture, Vector2 pos, bool center)
        {
            _texture = texture;
            if (center)
            {
                pos.X -= _texture.Width / 2;
                pos.Y -= _texture.Height / 2;
            }
            _position = pos;
        }
        public bool isHover(Vector2 mouse)
        {
            return (mouse.X >= _position.X && mouse.X <= _position.X + _texture.Width) && (mouse.Y >= _position.Y && mouse.Y <= _position.Y + _texture.Height);
        }
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(_texture, _position,filterColor);
        }
        /*public void Draw(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch,Color filterColor)
        {
            spriteBatch.Draw(_texture, _position, filterColor);
        }*/
    }
}
